﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Handrise.BasicModal.Serialization;

namespace Handrise.CDCable.Business
{
    /// <summary>
    /// 轨迹跟踪服务
    /// </summary>
    public class GPSTraceService
    {
        private ServerExchange serverExchange = new ServerExchange();
        
        public bool UploadGPSTrace(string userName, byte[] gpsTracesBuffer)
        {
            CompactFormatterPlus cfp = new CompactFormatterPlus();
            List<GPSTrace> gpsTraces = (List<GPSTrace>)cfp.Deserialize(gpsTracesBuffer);

            string entitysXML = CommonFunction.GetXMLFromEnitys<GPSTrace>(gpsTraces, typeof(GPSTrace));

            string receiveData = serverExchange.UploadGPSTrace(userName, entitysXML);

            return CommonFunction.ReturnDataIsOk(receiveData);
        }
    }
}
